<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="EmployTable">
    <div class="layui-card-body padding-left-40 layui-col-space10">
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("封面图")}:</label>
            <div class="layui-input-block">

                <input type="hidden" name="logo" value="{$vo.logo|default=''}" >
                <script>$('[name=logo]').uploadOneImage();</script>
            </div>
        </div>

        {if $account_show}
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("学校")}:</label>
            <div class="layui-input-block">

                <select name="account_id" lay-search class="layui-select" lay-filter="platform">
                    <option value=''>-- {:lang('全部')} --</option>
                    {foreach $account_arr as $key => $name}

                    <option value="{$key}" >{$name|default=''}</option>

                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("老师")}:</label>
            <div class="layui-input-block">

                <select class="layui-select teacher" name="user_id">
                    <option value=''>-- {:lang('全部')} --</option>
                    {foreach $teacher_arr as $k=>$v}

                    <option  value="{$k}">{$v}</option>

                    {/foreach}
                </select>
            </div>
        </div>
        {/if}


        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("标题")}:</label>
            <div class="layui-input-block">

                <input name="title" value='{$vo.title|default=""}' placeholder="请输入标题" required class="layui-input ">
            </div>
        </div>
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("所属分类")}:</label>
            <div class="layui-input-block">

                <input name="sub_category_id" class="layui-input" id="sub_category_list" required lay-verify="required">
            </div>
        </div>
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("简介")}:</label>
            <div class="layui-input-block">

                <textarea name="details" placeholder="请输入简介" lay-verify="" style="height: 250px" class="layui-textarea" >{$vo.details|default=""}</textarea>
            </div>
        </div>


    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit' lay-submit="">保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<link rel="stylesheet" href="__ROOT__/static/plugs/layui_exts/layCascader.css">
<script>
    $(function () {
        layui.use(['jquery', 'layCascader'], function () {
            let layCascader = layui.layCascader;
            let codeData = JSON.parse('{:json_encode($category_data)}');

            layCascader({
                elem:  "#sub_category_list"
                ,clearable: true
                ,props:{
                    checkStrictly:true,
                    expandTrigger: 'hover',
                    value:'id',
                    label:'name',
                    children:'sub'
                }
                ,filterable:true
                ,options:codeData
            });

            form.on('select(platform)', function(data){
                $.ajax({
                    type : 'get',
                    url  : "{:sysuri('common/ajax/getTeacherList')}",
                    data : {account_id:data.value},
                    success:function (res) {
                        if (res.code == 1) {
                            var html = "<option value=''>{:lang('-- 请选择 --')}</option>";

                            let data = res.data;
                            for (var i in data) {

                                html += "<option value='"+i+"'>"+data[i]+"</option>";
                            }

                            $('.teacher').html(html);

                            layui.form.render('select'); // 仅渲染 select 元素
                        }
                    }
                })
            });
        });
    })
</script>